package logic

import (
	"context"
	"person/personrpc/personrpc"

	"person/personapi/internal/svc"
	"person/personapi/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type PerfectUserLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewPerfectUserLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PerfectUserLogic {
	return &PerfectUserLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *PerfectUserLogic) PerfectUser(req *types.PerfectUserRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	user, err := l.svcCtx.PersonRpc.PerfectUser(l.ctx, &personrpc.PerfectUserRequest{
		Name:        req.Name,
		Marry:       req.Marry,
		Avatar:      req.Avatar,
		Certificate: req.Certificate,
		Gender:      req.Gender,
		DateBirth:   req.DateBirth,
		Mobile:      req.Mobile,
	})
	if err != nil {
		return &types.Response{
			Code:    500,
			Message: "完善信息失败",
			Data:    nil,
		}, nil
	}
	return &types.Response{
		Code:    200,
		Message: "完善信息成功",
		Data:    user.Id,
	}, nil
}
